package com.ax.center.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zy
 * @date 2023/5/15 20:00
 */

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInceptor())
                .excludePathPatterns(
                        "/loginController/login/**",
                        "/userController//updatePW/**"
                )
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html/**")
                .order(1);

        registry.addInterceptor(new RefreshInceteptor(redisTemplate))
                .addPathPatterns("/**")// 拦截所有请求
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html/**")
               .order(0);
        // 排除登录页面
    }






}
